<template>
  <div class="ele-body">
    <el-card shadow="never">
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :datasource="url"
        :columns="columns"
        :where="where"
        height="calc(100vh - 315px)">
        <template slot="action" slot-scope="{row}">
          <el-link
            type="primary"
            :underline="false"
            icon="el-icon-edit"
            @click="openEdit(row)"
            v-if="permission.includes('sys:signconfig:edit')">修改
          </el-link>

        </template>
      </ele-pro-table>
    </el-card>

    <!-- 编辑弹窗 -->
    <sign-edit
      :data="current"
      :visible.sync="showEdit"
      @done="reload"/>
  </div>
</template>

<script>
import {mapGetters} from "vuex";
import SignEdit from './sign-edit.vue';
// import Tools from "@/config/tools";


export default {
  name: 'SystemSign',
  components: {SignEdit},
  computed: {
    ...mapGetters(["permission"]),
  },
  data() {
    return {
      // 表格数据接口
      url: '/admin/config.signconfig/index',
      // 表格列配置
      columns: [
        {
          columnKey: 'selection',
          type: 'selection',
          width: 45,
          align: 'center',
          fixed: "left"
        },
        {
          prop: 'ItemIndex',
          label: '签到标识',
          width: 150,
          align: 'center',
          showOverflowTooltip: true,
          fixed: "left"
        },
        {
          prop: 'ItemType',
          label: '奖项类型',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 150,
          formatter: (row, column, cellValue) => {
            if (cellValue == 0) {
              return '金币'
            }
            return '实物'
          }

        },
        {
          prop: 'ItemCount',
          label: '签到金币',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 150
        },
        {
          prop: 'Remark',
          label: '备注说明',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 90,
          align: 'center',
          resizable: false,
          slot: 'action',
          fixed: "right"
        }

      ],
      // 表格搜索条件
      where: {},
      // 当前编辑数据
      current: null,
      // 是否显示编辑弹窗
      showEdit: false,
      // 筛选日期范围
      // daterange: null,
      // 日期时间选择器快捷项
    };
  },
  methods: {
    /* 刷新表格 */
    reload() {
      this.$refs.table.reload({where: this.where});
    },
    /* 重置搜索 */
    reset() {
      this.where = {};
      this.daterange = null;
      this.reload();
    },
    openEdit(row) {
      console.log(row)
      this.current = row;
      this.showEdit = true;
    },
    /* 日期选择改变回调 */
  }
}
</script>

<style scoped>
</style>
